#员工管理模块接口对象层

import requests
from common.logging_use import log


class IhrmEmpCURD(object):


    #添加员工
    @classmethod
    def add_emp(cls, header, json_data):
        url = "https://ihrm-java.itheima.net/api/sys/user"
        resp = requests.post(url=url, headers=header, json=json_data)
        log.info(resp.json())
        return resp

    #查询员工
    @classmethod
    def query_emp(cls, emp_id, headers):
        url = "https://ihrm-java.itheima.net/api/sys/user/"+ emp_id
        resp = requests.post(url=url, headers=header)
        return resp

    #修改员工
    @classmethod
    def modify_emp(cls, url,headers, json_data):
        resp = requests.put(url, headers=header, json=json_data)
        return resp

    #删除员工
    @classmethod
    def modify_emp(cls, url, headers, json_data):

        resp = requests.delete(url_query, headers=header)
        return resp

if __name__ == '__main__':
    head_add = {"Content-Type":"application/json", "Authorization":"bearer <KEY>"}
    data_add = {
    "username":"业务猪001",
    "mobile": "13789456120",
    "workNumber": "9527"
}
    resp = IhrmEmpCURD.add_emp(head_add, data_add )
    print("添加", resp.json())

    emp_id = "1436414153616463"
    resp = IhrmEmpCURD.query_emp(emp_id, header)
    print("查询", resp.json())

    data = {"username":"齐天大圣"}
    resp = IhrmEmpCURD.modify_emp(emp_id, header, data)
    print("修改", resp.json())

    resp = IhrmEmpCURD.modify_emp(emp_id, header, data)
    print("删除", resp.json())